﻿
$(document).ready(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			loginName:{
				required:true,
				minlength:4,
				maxlength:16
			},
			password:{
				required:true,
			},
			password2:{
				required:true,
				equalTo: "#password"
			},
			realName:{
				required:true,
			},
			
			salt:{
				required:true,
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
	});
	
	var id = $("#id").val();
	if(id != ''){
		//回填数据
		ajaxRequestJson("getUserManager",{
			"id":id
		},function(result){
			$("#form-admin-add").populate(result,"");
		})
	}
	
	$("#sub_mitbtn").on("click",function(){
		if($("#form-admin-add").valid()){
			var json_str = $("#form-admin-add").serializeJson();
			if(id != ''){
				ajaxRequestJson("updateUserManager",json_str,function(sh_result){
					if(sh_result>0){
						show_alert('修改成功',function(){layer_close()});
					}
				});
			}else{
				ajaxRequestJson("saveUserManager",json_str,function(sh_result){
					if(sh_result>0){
						
						show_alert('保存成功',function(){layer_close()});
						
					}
				});
			}
		}
	})
	
	
	
});




